/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facade;

import entity.Comments;
import entity.Orders;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaQuery;

/**
 *
 * @author Svetlana Shikhutskaya
 *  modified by Tkach Andrey
 */
@Stateless
public class CommentsFacade extends AbstractFacade<Comments> implements CommentsFacadeLocal {
    @PersistenceContext(unitName = "Delta-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CommentsFacade() {
        super(Comments.class);
    }

    @Override
    public List<Comments> findByOrder(Orders idOrder) {
          return getEntityManager()
                 .createNamedQuery("Comments.findByIdOrder", Comments.class)
                 .setParameter("idOrder", idOrder)
                 .getResultList();
        
     }
    
}
